package myWeb;

import java.io.IOException;
import java.util.Date;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import prender.InitializableBean;

public class HelloWorld extends HttpServlet {
	
	public static class Model /* implements InitializableBean */ {
		
		Model(String message) {
			this.message = message;
		}
		private String message;
		public String getMessage() {
			return message;
		}
		
		public void initialize() {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
			}
		}
	}

	
	
	private static final Logger logger = Logger.getLogger("HelloWorld");
	
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	logger.debug("doGet: enter");
    	
    	request.setAttribute("headerModel", new Model("this is header"));
    	request.setAttribute("footerModel", new Model("this is footer"));

    	RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/example1/main.jsp");
    	dispatcher.include(request,  response);
    	
    	logger.debug("doGet: exit");
    }
}
